<template>
    <div>
        <h1>登录</h1>
        <table>
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="data.name">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="data.pos">
                    </td>
                </tr>
                <tr>
                   
                    <td colspan="2">
                        <input type="button" value="登录" @click="deng">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import axios from 'axios';
import { useRoute} from 'vue-router';
const data=ref ({
    "id": 0,
  "name": "",
  "pos": ""
})
  const deng=()=>{
    if(data.value.name==""){
        alert('用户名不能为空');
        return;
    }
    if(data.value.pos==""){
        alert('密码不能为空');
        return;
    }
    axios.get("https://localhost:7176/api/Member/Login",{params:data.value}).then(res=>{
        if(res.data.id>0){
            alert('登录成功');
        }
        if(res.data.id==-1){
            alert('用户名不存在');
            return;
        }
        if(res.data.id==-2){
            alert('密码错误');
            return;
        }
       
    })
  }
</script>